<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <!-- Content Header (Page header) -->
    <include file="Public/breadcrumb"/>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading"> 
                    <h3 class="panel-title"><i class="fa fa-list"></i> 订单列表</h3>
                </div>
                <div class="panel-body new-panel-body"> 
                    <div class="navbar">
                            <form action="#" id="search-form2" class="navbar-form form-inline" method="post">
								<div class="form-group">
								    <div class="input-group">
								        <input type="text" name="order_sn" id="order_sn" placeholder="订单编号" id="input-order-id" class="form-control">
								    </div>
								</div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="consignee" id="consignee" placeholder="收货人/档铺名/手机" id="input-member-id" class="form-control">
                                    </div>
                                </div>
								<div class="form-group">
								    <div class="input-group">
								        <input type="text" name="goods_name" id="goods_name" placeholder="产品名称" id="input-order-id" class="form-control" style="border:1px solid #337ab7;width:150px;">
								    </div>
								</div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="timegap" value="{$timegap}" placeholder="下单日期"  id="add_time" class="form-control" style="width: 220px;">
					                 </div>
                                </div>
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="biaoshi_xian" id="biaoshi_xian" placeholder="线路" id="input-b1" class="input-sm" value="{:I('biaoshi_xian')}" style="width:100px;">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <select id='fast_flag' name="fast_flag" class="input-sm">
                                        <option value="">是否快线</option>
                                        <option value="1" <?php if(I('fast_flag')=='1'){echo 'selected="selected"';};?>>是</option>
                                        <option value="0" <?php if(I('fast_flag')=='0'){echo 'selected="selected"';};?>>否</option>
                                    </select>
                                </div>
<!--                                <div class="form-group">
                                    <select name="pay_status" class="input-sm" style="width:100px;">
                                            <option value="">支付状态</option>
                                            <option value="0">未支付</option>
                  		            <option value="1">已支付</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <select name="pay_code" class="input-sm" style="width:100px;">
                                        	<option value="">支付方式</option>
                                            <option value="alipay">支付宝支付</option>
                  							<option value="weixin">微信支付</option>
                  							<option value="cod">货到付款</option>
                                    </select>
                                </div> -->
<!--                                <div class="form-group">
                                    <select name="shipping_status" class="input-sm" style="width:100px;">
                                        	<option value="">发货状态</option>
                                            <option value="0">未发货</option>
                  							<option value="1">已发货</option>
                  							<option value="2">部分发货</option>
                                    </select>
                                </div> -->
                                <div class="form-group">
									<?php
									if(I('order_status')==""){
									?>
                                    <select name="order_status" id="order_status" class="form-control" style="width:110px;">
                                        <option value="">订单状态</option>
                                        <volist name="order_status" id="v" key="k">
                                            <option value="{$k-1}">{$v}</option>
                                        </volist>
                                        <if condition="STORE_ID eq 5">
                                        <option value="99">球王导出</option>
                                        </if>
                                    </select>
									<?php
									}elseif(I('order_status')!=""){
										echo '<input type="hidden" name="order_status" id="order_status" value="'.I('order_status').'">';
									}else{
										echo '<input type="hidden" name="order_status" id="order_status" value="35">';
									}
									?>
                                    <input type="hidden" name="order_by" value="order_id">
                                    <input type="hidden" name="sort" value="desc">
                                </div>
                                <div class="form-group" style="margin-left:13px;">
                                	<a href="javascript:void(0)" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</a>
                                </div>
                                <div class="form-group" style="margin-left:13px;">
                                	<a href="/index.php?m=Seller&c=Order&a=add_order" class="btn btn-primary"><i class="fa fa-plus"></i> 代客下单</a>
                                </div>   
                                <if condition="I('order_status') == '0' ">
                                <div class="form-group">
                                	<a href="javascript:;" onclick="oneClickMerge()" class="btn btn-primary"> 一键合并订单</a>
									<!-- <span style="color: red;">已放假，暂停代客下单，感谢支持。</span> -->
                                </div>
                                </if>
                                <button type="button" class="btn btn-primary pull-right" id="daidaochu"><i class="fa fa-file-excel-o"></i>&nbsp;拣货清单</button>
                                <button type="button" class="btn btn-primary pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;订单导出xls</button>
                                <button type="button" class="btn btn-primary pull-right" id="daochu3"><i class="fa fa-file-excel-o"></i>&nbsp;产品导出xls</button>
                                <!--<if condition="STORE_ID eq 5">-->
                                <!--<button type="button" class="btn btn-primary pull-right" id="daochu2"><i class="fa fa-file-excel-o"></i>&nbsp;导出erp</button>  -->
                                <!-- </if>-->
                                 <if condition="STORE_ID eq 13">
                                <button type="button" class="btn btn-primary pull-right" id="daochu2"><i class="fa fa-file-excel-o"></i>&nbsp;导出管家婆erp</button>  
                                 </if>
                            </form>
							<span style="color: red; padding: 5px 15px; display: block;">温馨提醒：商家只需打印单据、标签进行拣货包装，捡好货后把货送到联鑫壹天达仓库即可！订单状态和收付款平台自动化。<b>（如有需合并、拆单，先合并或者拆单再打印标签！）</b></span>
                    </div>
                    <div id="ajax_return">

                    </div>

                </div>
            </div>
        </div>        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>
    $(document).ready(function(){
        ajax_get_table('search-form2',1);
        
		$('#add_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
			showWeekNumbers: true,
			timePicker: true,
			timePickerIncrement: 1,
			timePicker12Hour: false,
			ranges: {
			   '今天': [moment(), moment()],
			   '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
			   '最近7天': [moment().subtract('days', 6), moment()],
			   '最近30天': [moment().subtract('days', 29), moment()],
			   '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
			},
			opens: 'left',
			buttonClasses: ['btn btn-default'],
			applyClass: 'btn-small btn-primary',
			cancelClass: 'btn-small',
			locale : {
			    applyLabel : '确定',
			    cancelLabel : '取消',
			    fromLabel : '起始时间',
			    toLabel : '结束时间',
			    customRangeLabel : '自定义',
			    daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
			    monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
			    firstDay : 1
			}
		});
		
    });

	$("input[name=order_sn],input[name=consignee]").keydown(function(e){
		if (e.keyCode == "13") {
			ajax_get_table('search-form2',1);
		};
	});

	$("#daochu").click(function(){
		var order_sn=$("#order_sn").val();
		var consignee=$("#consignee").val();
		var add_time=$("#add_time").val();
		var order_status=$("#order_status").val();
		var fast_flag=$("#fast_flag").val();
		var goods_name=$("#goods_name").val();
		var biaoshi_xian=$("#biaoshi_xian").val();
		order_status==undefined?order_status="":order_status;
		location.href="/index.php/Seller/order/export_order?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+add_time+"&order_status="+order_status+"&fast_flag="+fast_flag+'&goods_name='+goods_name+'&biaoshi_xian='+biaoshi_xian;
	})	
	$("#daochu3").click(function(){
		var order_sn=$("#order_sn").val();
		var consignee=$("#consignee").val();
		var add_time=$("#add_time").val();
		var order_status=$("#order_status").val();
		var fast_flag=$("#fast_flag").val();
		var goods_name=$("#goods_name").val();
// 		order_status==undefined?order_status="":order_status;
		if(order_status==undefined){
		    order_status=""
		}
		location.href="/index.php/Seller/order/export_order2?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+add_time+"&order_status="+order_status+"&fast_flag="+fast_flag+'&goods_name='+goods_name;
	})
	$("#daochu2").click(function(){
		var order_sn=$("#order_sn").val();
		var consignee=$("#consignee").val();
		var add_time=$("#add_time").val();
		var order_status=$("#order_status").val();
		var fast_flag=$("#fast_flag").val();
		var goods_name=$("#goods_name").val();
// 		?order_status="":order_status;
		if(order_status==undefined){
		    order_status=""
		}
		location.href="/index.php/Seller/order/guanjiapo?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+add_time+"&order_status="+order_status+"&fast_flag="+fast_flag+'&goods_name='+goods_name;
	})
	$("#daidaochu").click(function(){
		var fast_flag=$("#fast_flag").val();
		var add_time=$("#add_time").val();
		location.href="/Seller/order/daiexports?timegap="+add_time+'&fast_flag='+fast_flag;
	})

    // ajax 抓取页面
    function ajax_get_table(tab,page){
        cur_page = page; //当前页面 保存为全局变量
            $.ajax({
                type : "POST",
                url:"/index.php/Seller/order/ajaxindex/p/"+page,//+tab,
                data : $('#'+tab).serialize(),// 你的formid
                success: function(data){
                    $("#ajax_return").html('');
                    $("#ajax_return").append(data);
                }
            });
    }

    // 点击排序
    function sort(field)
    {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
   function oneClickMerge(){
      layer.confirm('合并订单不包含填写了标签数的订单，如要合并请填写0，合并订单之后一定要重新填写打印标签', {
			  title:'系统警告！',
			  btn: ['确定合并','取消'] //按钮
			}, function(){
        		$.ajax({
                    type : "POST",
                    url:"/index.php/Seller/order/oneClickMerge",//+tab,
                    data :{},// 你的formid
                    success: function(data){
                        layer.alert('合并成功', {icon: 1});
                        ajax_get_table('search-form2',1);
                    }
                });
		            
			});       
    }
	//批量打印操作提交
	    function dayin(type) {
	        
	        //prompt层
	        var ids = get_select_order_id_str();
	        console.log(ids)
	        if (ids == false) {
	            layer.alert('请勾选要打印的订单', {icon: 2});
	            return;
	        }
	        layer.open({
	            type: 2,
	            title: '批量打印预览',
	            shadeClose: true,
	            shade: 0.3,
	            area: ['80%', '80%'],
	            content:'/index.php/Seller/Order/order_print_pl/order_ids/'+ids, 
	        });
	}
</script>
</body>
</html>